#include "forward_classes.h"
#include "preprocessor.h"

#ifndef _DEBUGGER_HEADER_ 
#define _DEBUGGER_HEADER_
//***************************************************************************************************/
class debugger { // interface class that handles debugging of diag scripts, preprocessor, and compilation
	// stages of model building. i
	class local;   // local collection of static functions that do not need global scope definitions.
	private:
	bool breakpoint; // trap on next instruction (used for stepping)
	bool trap;  // trap on exit of current function (used with continues)

	int last_line;

	model_class * mo;

	vector< model_diagnostics_block * > cdiag;
	vector< bool > traps; 

	qstream DBGOUT; // debug input/output streams
	qstream DBGIN;

	explicit debugger(const debugger &); // no copy constructors allowed
	explicit debugger(); // no default constructor

	public: 
	explicit debugger(model_class * mo);

	bool filterblock(int cinstr, bool debug = false);

	bool filtercompiler(model_class * mo, const string &, const vector<token> & , const int pos);
	bool filterpreprocessor(); 

	// break and trap handlers
	void setbreakpoint();
	void removebreakpoint();
	bool isbreakpointon() const;

	bool removebreakpointbyfile(const char * namelist, int line_number);
	bool setbreakpointbyfile(const char * namelist, int line_number);
	bool setbreakpointbyfunction(const char * func_name);
	bool removebreakpointbyfunction(const char * func_name);
	void removeallbreakpoints();

	// stack handlers
	void pushblock(model_diagnostics_block *);
	void popblock();

	// IO handlers
	const qstream & getDBGOUT() const;
	qstream & getDBGIN();
	bool setDBGIN(const char *);
	bool setDBGOUT(const char *);
	bool setDBGIN(FILE *);
	bool setDBGOUT(FILE *);
	void closeDBGIO();
	bool isdebugIOvalid() const;

};

#endif
